﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HomePortal.Models
{
    public class AccountRepository: IAccountRepository
    {
        HomePortalContext context = new HomePortalContext();


        public IQueryable<UserProfile> All
        {
            get { return context.UserProfiles; }
        }

        public UserProfile Find(int id)
        {
            return context.UserProfiles.Find(id);
        }

        public void InsertOrUpdate(UserProfile userProfile)
        {
            throw new NotImplementedException();
        }

        public void Delete(int id)
        {
            throw new NotImplementedException();
        }

        public void Save()
        {
            throw new NotImplementedException();
        }

        public IQueryable<UserProfile> FindByName(string name)
        {
            return context.UserProfiles.Where(u=>name != null && u.UserName == name);
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }
    }


    public interface IAccountRepository : IDisposable
    {
        IQueryable<UserProfile> All { get; }
        UserProfile Find(int id);
        void InsertOrUpdate(UserProfile userProfile);
        void Delete(int id);
        void Save();
        IQueryable<UserProfile> FindByName(string name);
    }
}